package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.InterviewRegistration;
import com.ruoyi.system.service.IInterviewRegistrationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 面试登记Controller
 * 
 * @author jzy
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/interview/interviews")
public class InterviewRegistrationController extends BaseController {


    @Autowired
    private IInterviewRegistrationService interviewRegistrationService;

    /**
     * 查询面试登记列表
     */
    @RequiresPermissions("interview:interviews:list")
    @GetMapping("/list")
    public TableDataInfo list(InterviewRegistration interviewRegistration)
    {
        startPage();
        List<InterviewRegistration> list = interviewRegistrationService.selectInterviewRegistrationList(interviewRegistration);
        return getDataTable(list);
    }

    /**
     * 导出面试登记列表
     */
    @RequiresPermissions("interview:interviews:export")
    @Log(title = "面试登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InterviewRegistration interviewRegistration)
    {
        List<InterviewRegistration> list = interviewRegistrationService.selectInterviewRegistrationList(interviewRegistration);
        ExcelUtil<InterviewRegistration> util = new ExcelUtil<InterviewRegistration>(InterviewRegistration.class);
        util.exportExcel(response, list, "面试登记数据");
    }

    /**
     * 获取面试登记详细信息
     */
    @RequiresPermissions("interview:interviews:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(interviewRegistrationService.selectInterviewRegistrationById(id));
    }

    /**
     * 新增面试登记
     */
    @RequiresPermissions("interview:interviews:add")
    @Log(title = "面试登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InterviewRegistration interviewRegistration)
    {
        return toAjax(interviewRegistrationService.insertInterviewRegistration(interviewRegistration));
    }

    /**
     * 修改面试登记
     */
    @RequiresPermissions("interview:interviews:edit")
    @Log(title = "面试登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InterviewRegistration interviewRegistration)
    {
        return toAjax(interviewRegistrationService.updateInterviewRegistration(interviewRegistration));
    }

    /**
     * 删除面试登记
     */
    @RequiresPermissions("interview:interviews:remove")
    @Log(title = "面试登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(interviewRegistrationService.deleteInterviewRegistrationByIds(ids));
    }
}
